package com.cebbank.yyi.springbootapp.jingtang.enums;

import lombok.Getter;
import lombok.RequiredArgsConstructor;

@RequiredArgsConstructor
@Getter
public enum DocUserTypeEnum {

    AUTHOR(InnerDocUserTypeEnum.PREPARED, "AUTHOR", "编制人"),
    APPROVAL(InnerDocUserTypeEnum.REVIEWER, "APPROVAL", "审批人"),
    SIGN(InnerDocUserTypeEnum.ISS, "SIGN", "签发"),
    COM_MAIN(InnerDocUserTypeEnum.NULL, "COM_MAIN", "公司主管领导"),
    REPEAL(InnerDocUserTypeEnum.NULL, "REPEAL", "废止人员"),
    REPEAL_APPROVAL(InnerDocUserTypeEnum.NULL, "REPEAL_APPROVAL", "废止审批人"),
    REPEAL_SIGN(InnerDocUserTypeEnum.NULL, "REPEAL_SIGN", "废止签发"),
    REPEAL_COM_MAIN(InnerDocUserTypeEnum.NULL, "REPEAL_COM_MAIN", "废止公司主管"),
    PRO_DEPT(InnerDocUserTypeEnum.NULL, "PRO_DEPT", "生产技术文件会签部门"),
    PRO_SUIT_DEPT(InnerDocUserTypeEnum.NULL, "PRO_SUIT_DEPT", "生产技术文件适用部门"),
    SYSTEM_USER(InnerDocUserTypeEnum.NULL, "SYSTEM_USER", "制度负责人");

    private final InnerDocUserTypeEnum oldId;

    private final String name;

    private final String displayName;

    public static DocUserTypeEnum getByOldId(InnerDocUserTypeEnum oldId) throws Exception {
        if (oldId == null) {
            System.out.print("DocUserTypeEnum：老系统ID为空");
            return null;
        }
        for (DocUserTypeEnum type : DocUserTypeEnum.values()) {
            if (oldId.equals(type.getOldId())) {
                return type;
            }
        }
        throw new Exception("DocUserTypeEnum：老系统ID映射失败，当前OLD_ID为：" + oldId);
    }

    @Getter
    @RequiredArgsConstructor
    public enum InnerDocUserTypeEnum {

        PREPARED,
        ISS,
        REVIEWER,
        NULL;
    }
}
